/**
 * 
 */
package com.ekingstar.framework.service.impl;

import java.util.Properties;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.ekingstar.framework.domain.Function;
import com.ekingstar.framework.service.IGenerateService;

/**
 * 
 *
 */
public class GenerateServiceImpl implements IGenerateService,InitializingBean {

	/* (non-Javadoc)
	 * @see com.ekingstar.framework.service.IGenerateService#gengerateCodeFromFunction(java.lang.String)
	 */
	private HibernateTemplate hibernateTemplate;
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	private Resource config;
	public void setConfig(Resource config) {
		this.config = config;
	}
	public boolean gengerateCodeFromFunction(String id) {
		// TODO Auto-generated method stub
		Function function = (Function)hibernateTemplate.get(Function.class, id);
		if (!Boolean.TRUE.equals(function.getLeaf())) return false;
		String functionAddress = function.getAddresss();
		Integer ft = function.getFunctionType();
		//
		
		try{
			
		}catch(Throwable e){
			e.printStackTrace();
		}
		return false;
	}
	private String mainSpringPath;
	private String sessionFactoryId;
	public void afterPropertiesSet() throws Exception {
		// TODO Auto-generated method stub
		Properties configValues = new Properties();
		configValues.load(config.getInputStream());
		mainSpringPath = configValues.getProperty("springPath")+"/"+configValues.getProperty("mainSpringName");
		sessionFactoryId = configValues.getProperty("sessionFactoryId");
	}

}
